#ifndef COMPONENTSELECTION_H
#define COMPONENTSELECTION_H

#include <cmath>
#include <vector>
#include <string>
#include <sstream>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/ModelCoefficients.h>
#include <pcl/sample_consensus/method_types.h>
#include <pcl/sample_consensus/model_types.h>
#include <pcl/segmentation/sac_segmentation.h>
#include <pcl/search/kdtree.h>
#include <pcl/segmentation/extract_clusters.h>

/*!
 \file componentSelection.h This file contains the component selection functions.
 \author Sqizzato Stefano
 \author Maroso Alessandro

*/

using namespace std;
using namespace pcl;

/*!
 \brief Finds the cluster, between all the clusters it receives in input, which has a specified point in it, represented by its index.

 \param[out] output The output indices of the points representing the cluster extracted.
 \param[in] cluster_indices_out The input vector of set of indices, representing the set of clusters that are present in the cloud.
 \param[in] selectedPointIndex The input index of the point of the cluster to find.
*/
void segmentCluster(PointIndices::Ptr output, vector<PointIndices> cluster_indices_out, int selectedPointIndex);

/*!
 \brief Finds the cluster, between all the clusters it receives in input, which contains the nearest point to the input point.

 \param[in] input The input cloud.
 \param[out] output The output cluster's indices.
 \param[in] cluster_indices_out The input vector of set of indices, representing the set of clusters that are present in the cloud.
 \param[in] clicked The input point defining the cluster to be found.
*/
void segmentClusterNearestPoint(PointCloud<PointXYZRGB>::Ptr input, PointIndices::Ptr output, vector<PointIndices> cluster_indices_out, PointXYZRGB clicked);

/*!
 \brief Performs a color segmentation on the input cloud from the selectedPointIndex and returns the pointIndices of the cluster found.

 \param[in] input The input cloud.
 \param[out] output The output cluster's indices.
 \param[in] selectedPointIndex The input index of the point of the cluster to find.
 \param[in] threshold The input color threshold.
*/
void segmentColor(PointCloud<PointXYZRGB>::Ptr input, PointIndices::Ptr output, int selectedPointIndex, int threshold);

/*!
 \brief Gives the intersection of two point indices vectors.

 \param[in] first The first input set of indices.
 \param[in] second The second input set of indices.
 \param[out] intersection The output set of indices.
*/
void intersectIndices(PointIndices::Ptr first, PointIndices::Ptr second, PointIndices::Ptr intersection);

#endif // REGISTRATION_H












